package com.czy;

import com.alibaba.fastjson2.JSONObject;

import java.io.*;
import java.util.List;

public class 垃圾分类给所有住户添加卡号 {
    public static void main(String[] args) throws IOException {
        File file = new File("d:/1.txt");

        BufferedReader br = new BufferedReader(new FileReader(file));
        StringBuilder sb = new StringBuilder();
        String s;
        while ((s = br.readLine()) != null) {
            sb.append(s);
        }
        br.close();
        JSONObject json = JSONObject.parseObject(sb.toString());
        List<JSONObject> rows = json.getJSONArray("rows").toJavaList(JSONObject.class);
        StringBuilder sql = new StringBuilder();
        sql.append("insert into zhgl_card(card_no,bucket_type,house_id,is_enable,remark,is_delete) values ");
        for (JSONObject row : rows) {
            sql.append("(")
                    .append("'").append(row.getString("phone")).append("'").append(",")
                    .append("0").append(",")
                    .append(row.getString("houseId")).append(",")
                    .append("1").append(",")
                    .append("null").append(",")
                    .append("0").append("),");
        }
        sql.deleteCharAt(sql.length() - 1);
        System.out.println(sql);
    }
}
